package com.smh.aiagent.agent.config;

import com.smh.aiagent.advisers.MyLoggerAdvisor;
import com.smh.aiagent.agent.SmhAgent;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.ai.tool.ToolCallback;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author shiminghui
 * @date 2025/6/8 17:02
 * @description: TODO
 */
@Configuration
public class AgentConfig {
    @Bean
    @ConditionalOnMissingBean
    public SmhAgent smhAgent(ChatModel dashscopeChatModel, ToolCallback[] allTools) {

        ChatClient chatClient = ChatClient.builder(dashscopeChatModel)
                .defaultAdvisors(new MyLoggerAdvisor())
                .build();

        return SmhAgent.builder()
                .name("smh-agent")
                .description("smh-agent")
                .chatClient(chatClient)
                .availableTools(allTools)
                .maxStep(20)
                .build();
    }
}
